﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="adminResource.aspx.cs" Inherits="Admin_adminResource"  EnableViewState="false" EnableSessionState="False" %>

<%@ Register Src="adminfoot.ascx" TagName="adminfoot" TagPrefix="uc1" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>无标题页</title>
    <link rel="stylesheet" href="imgs/admin.css" type="text/css" media="all" />
    <script type="text/javascript" src="../DotNet_net/js/jquery-1.3.2.min.js"></script>
    <script type="text/javascript" src="imgs/GetAjax.js"></script>
    <script type="text/javascript" src="../DotNet_net/js/common.js"></script>
</head>
<body onload="$('#loading').hide()">
  <form id="form1" runat="server">
<div class="container" id="cpcontainer">
<div id="loading" style="display:block">   
    <div class="loading-indicator">   
        页面正在加载中...   
    </div>   
</div> 

    <ul id="makeHtmlTab">
<li class="hover"><a href="javascript:void(0)">资源信息</a>
    </li>
</ul>
    <table class="tb" id="TABLE1">
        <tr><td align="left" colspan="12">关键字<input  name="keyword" type="text" id="keyword" size="20" /> <%=resourceClassDp("resourceClassId")%><input type="button" name="selectBtn"  value="查 询..." class="btn" onclick='SelectKey("?")'/>&nbsp;
                <input id="Button1" class="btn" type="button" value="添  加" onclick="javascript:location.href=location.href;"/></td>
</tr>
        <tr>
			<td align="left" style="height: 17px; width: 129px;">
                资源ID*(ResourceID)</td>
			<td  style="height: 17px; width: 148px;">
                资源名称(ResourceName)</td>
			<td  style="height: 17px; width: 145px;">
                资源类别(ResourceClass)</td>
            <td style="height: 17px; width: 164px;">
                资源地址（ResourceURL）</td>
			<td  style="height: 17px; width: 230px;">&nbsp;操作（编辑资源，删除资源）</td>		
        </tr>
        
        <tr >
        <asp:Repeater ID="Repeater1" runat="server">     
      <ItemTemplate>      
<tr bgcolor="#f5fafe" >
	<td ><input type="checkbox" value='<%#Eval("ResourceID") %>' name="m_id"   class="checkbox" /><%#Eval("ResourceID")%></td>
	<td ><%#Eval("ResourceName")%></td>
	<td><%#getResourceClassByResourceClassID(Convert.ToInt32(Eval("ResourceClassID"))).ResourceClassName%></td>
	<td><%#Eval("ResourceURL")%></td>
	<td>
	  <input id="Button5" type="button" value="编辑" class='btn' title='<%#Eval("ResourceID") %>' onclick="$('#loading').show();ajax_get(convertURL('adminResource.aspx?state=edit&resourceID='+this.title+'&CurrentIndex='+'<%=_currentIndex%>'+'&ClassId='+'<%=_classid%>'+'&key='+'<%=_key%>'),'',function(msg){$('#cpcontainer').empty().append(msg);$('#loading').hide();});"/>
	   <input id="btnDel" type="button" value="删除" class='btn' title='<%#Eval("ResourceID") %>' onclick="if(confirm('确定要删除吗')){$('#loading').show();ajax_get(convertURL('adminResource.aspx?state=del&resourceID='+this.title),'',function(msg){if(msg!=1){$('#cpcontainer').empty().append(msg);$('#loading').hide();}else{alert('资源正在使用中，无法删除！');$('#loading').hide();};});}else{return false}"/>	
		<input id="btn" type="button" value="解除关联" class="btn" title='<%#Eval("ResourceID") %>' onclick="if(confirm('确定要解除关联吗')){$('#loading').show();ajax_get(convertURL('adminResource.aspx?state=delTb&resourceID='+this.title),'',function(msg){alert(msg);$('#loading').hide();});}else{return false}" />      
	</td>
  </tr>   
      </ItemTemplate>  
      </asp:Repeater>              
        </tr>
        <tr>
        <td colspan="7"><div class="pages">
 <%htmlPaging();%></div></td>
        </tr>
        <tr><td colspan="7"><div class="cuspages"><div class="pages" id="pro">全选<input type="checkbox" name="chkall" id="chkall" class="checkbox" onclick="checkAll(this.checked,'m_id')" />反选<input type="checkbox" name="chkothers" id="chkothers" class="checkbox" onclick="checkOthers('m_id')" />
 <%=resourceClassDp("resourceClass_Dp")%>
<input type="button"   value="批量移动" class="btn" onclick="doPostMove('','m_id')"/>&nbsp;
    </div></div></td>
</tr>
        </table>
        <br />
<ul id="makeHtmlTab2"><li class="hover"><a href="javascript:void(0)" >添加/编辑资源</a></li></ul>
    <table class="tb" id="addRole">
        <tr align="center">
            <td style="width: 70px" >
                资源名称：
            </td>
            <td style="width: 124px">
                <input id="resourceName_txt" style="width:100px" type="text" name="resourceName_txt"  runat="server"  /><span style="color: #ff0000">＊</span></td>
            <td align="right" style="width: 56px">
                资源类别:</td>
            <td align="left" style="width: 140px">
                <span style="color: #ff0000">
                    <%=resourceClassDp("resourceClassDp")%>
                    ＊</span></td>
                    <td style="width: 91px">
                        资源地址：</td>
                        <td align="left"><iframe src="FileDownLoad/ZrNet_upLoadResource.htm" scrolling="no" topmargin="0" width="300" height="24" marginwidth="0" marginheight="0" frameborder="0"></iframe>
            <span style="color: #ff0000">支持文件类型gif|jpg|bmp|png|pdf，大小5M以下<input id="content" type="hidden" value=""  name="imgSrc" runat="server"/></span></td>
    </tr>
        <tr align="center">
            <td style="width: 70px; height: 128px">
                资源描述：</td>
            <td align="left" colspan="5" style="height: 128px">
                <textarea id="txt_description" name="txt_description" style="width: 555px; height: 145px" runat="server"></textarea></td>
        </tr>
        <tr align="center">
            <td align="center" colspan="8">                &nbsp;&nbsp;&nbsp;
                <input id="Insert" class="btn" onclick="InsertResource()" type="button" value="确认保存" />
               </td>
        </tr>
</table>
<input id="resource_hid" runat="server" type="hidden" value="0" name="resource_hid" />
        
<%=input%>
</div>   
<uc1:adminfoot ID="Adminfoot1" runat="server" />   
  </form>
<script type="text/javascript">
    function InsertResource()
    {  
        $("#loading").show();
        var url="";
        var Param='';       
        if($("#resource_hid").attr("value")!="0")
         {
            url=convertURL(url+"adminResource.aspx?state=update&resourceID="+$("#resource_hid").attr("value")); 
            Param+="&resourceName="+$("#resourceName_txt").attr("value")+"&resourceClassID="+$("#resourceClassDp option:selected").attr("value")+"&resourceURL="+$("#content").attr("value")+"&description="+$("#txt_description").attr("value");  
            ajax_post(url,Param,function(msg){   
            
                if(msg==2)
                {
                   alert("保存失败，填写不完整！");
                    $("#loading").hide();
                }
                else
                {
                    alert("修改成功！");
                   
                   location.href=location.href;
                }               
            });                                    
         }
         else
         {
             url=convertURL(url+"adminResource.aspx?state=Insert&resourceID="+$("#resource_hid").attr("value"));              
             Param+="&resourceName="+$("#resourceName_txt").attr("value")+"&resourceClassID="+$("#resourceClassDp option:selected").attr("value")+"&resourceURL="+$("#content").attr("value");                      
             ajax_post(url,Param,function(msg){
                if(msg==2)
                {
                    alert("添加失败，填写不完整！");
                    $("#loading").hide();
                }
                else
                {
                     alert("添加成功！");
                        
                     location.href=location.href;
                }         
            });                           
         }

    } 
    
   function SelectKey(url)
   {
      $("#loading").show();
      url=convertURL("adminResource.aspx?key="+escape($("#keyword").attr("value"))+"&ClassId="+$("#resourceClassId option:selected").attr("value")+"&CurrentIndex=1");
      ajax_get(url,'',function(msg)
      {
        $("#cpcontainer").empty().append(msg);   
        $("#loading").hide();       
      });       
   }
   
   
   function doPostMove(url,sname)
    {
      
        var ids=getIDList(sname);    
        var yidong="";
        var Param="";
        yidong=$("#resourceClass_Dp option:selected").attr("value");
        if((confirm("确定要移动这些记录?"))==true)
        {  $("#loading").show();
            url=convertURL(url+"adminResource.aspx?state=MoveAll&resourceClassId="+yidong+"&rid="+ids+"&resourceID="+$("#resource_hid").attr("value"));
            ajax_get(url,'',function(msg)
            {               
                 if(msg!=1)
                {
                    $("#cpcontainer").empty().append(msg); 
                    $("#loading").hide();
                }
                else
                {
                    alert("未选择你需要移动的项！");
                    $("#loading").hide();
                }         
            });
        }	    
    } 
</script>
    <script type="text/javascript" >
    function changePage(name)
    {
        
    }
    </script>
</body>
</html>
